package com.zqh.irmadscore.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zqh.irmadscore.model.entity.AlertDetail;
import com.zqh.irmadscore.service.AlertDetailService;
import com.zqh.irmadscore.utils.resultUtils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: zqh
 * @description: 报警细节
 * @date: 2025/3/26
 **/
@RestController
@RequestMapping("/alert")
@AllArgsConstructor
@Tag(name = "报警细节")
public class AlertDetailController {

    private final AlertDetailService alertDetailService;

    @GetMapping("getAlertDetailRank2")
    @Operation(summary = "获取报警细节")
    public Result<List<AlertDetail>>getAlertDetailRank2(
            @RequestParam(value = "报警等级")Integer alertRank ,
            @RequestParam(value = "监测道名字") String name) {

        LambdaQueryWrapper<AlertDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AlertDetail::getAlertRank, alertRank);
        // 模糊搜索
        queryWrapper.like(AlertDetail::getTractName, name);

        List<AlertDetail> alertDetailList = alertDetailService.list(queryWrapper);
        return Result.ok(alertDetailList);
    }


}
